/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package idea.security;


import epd.massdb.aas.AASClient;
import epd.massdb.aas.ws.Ldapinformation;
import java.util.HashMap;
import java.util.Map;
import org.openide.util.Exceptions;


/**
 *
 * @author rejun001
 */
public class Authenticator
{
    private static final Map<String, String> USERS = new HashMap<>();
    
    /**
     * Does MASSDB LDAP authentication
     * @param user
     * @param password
     * @return true if authenticated
     */
    public static boolean validate(String user, String password) {
        Ldapinformation userInfo = null;
        try
        {
            userInfo = AASClient.authenticateUser( user , password , "appName" );
            System.out.println( "user info " + userInfo.getFirstName() + userInfo.getLastName() + userInfo.getJbondid() );
        } catch ( Exception e )
        {
            System.out.println( e.getMessage() );
            return false;
        }
        return (userInfo.getLogged() == 1);
    }
}
